import { Notify } from 'vant';
import router from './../router'
export default ({
  namespaced: true,
  state: {
    dayAndNight: true,
    isLogin: true,
    user: {
      id: 1111,
      name: 'admin',
      userImg: 'http://pic1.zhimg.com/3e313e96a25b18b8236b241840a5d818_im.jpg'
    }
  },
  mutations: {
    change_dayAndNight(start, data) {
      console.log(start, data);
      if (data == 1) {
        start.dayAndNight = false;
        document.getElementById('app').className = 'te';
        document.querySelector('body').style.background = '#111';
      } else {
        start.dayAndNight = true;
        document.getElementById('app').className = '';
        document.querySelector('body').style.background = '#fff';
      }
    },
    chenge_isLogin(start, data) {
      if (data == 1) {//登录
        start.isLogin = true;
        Notify({
          type: "primary",
          message: "登录成功",
          duration: 1500
        });
      } else {//退出
        start.isLogin = false;
        Notify({
          type: "primary",
          message: "已退出登录",
          duration: 1500
        });
      }
      router.push('/')
    }
  },
  actions: {
    set_change_dayAndNight({ commit }, data) {
      commit('change_dayAndNight', data);
    },
    set_chenge_isLogin({ commit }, data) {
      commit('chenge_isLogin', data);
    }
  }
})
